package com.example.hanchen.yongkanggy.home.fragment;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.hanchen.yongkanggy.home.adapter.ControItemAdapter;
import com.example.hanchen.yongkanggy.home.adapter.FragmentListAdapter;
import com.example.hanchen.yongkanggy.home.adapter.WarnItemAdapter;
import com.google.android.material.tabs.TabLayout;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;

import com.example.hanchen.yongkanggy.R;
import com.example.hanchen.yongkanggy.home.adapter.MyAdapter;
import com.example.hanchen.yongkanggy.home.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;
/*
 * 监控
 * */

public class ControlFragment extends BaseFragment {
    TabLayout tabLayout;
    ViewPager viewPager;

    public static ControlFragment newInstance() {//int typePosition
        Bundle args = new Bundle();
        ControlFragment fragment = new ControlFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @SuppressLint("MissingInflatedId")
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_control, container, false);
        tabLayout = view.findViewById(R.id.tl_tablayout);
        viewPager = view.findViewById(R.id.view_pager);
        initData();
        return view;
    }

    private void initData() {
        List<Fragment> frameLayoutList = new ArrayList<Fragment>();
        frameLayoutList.add(new ControlitemFragment());
        frameLayoutList.add(new ControlitemFragment());
        frameLayoutList.add(new ControlitemFragment());
        frameLayoutList.add(new ControlitemFragment());


        List<String> tabLayoutList = new ArrayList<>();
        tabLayoutList.add("全部");
        tabLayoutList.add("重点人员");
        tabLayoutList.add("流动人员");
        tabLayoutList.add("常驻人口");


        ControItemAdapter adapter = new ControItemAdapter(getChildFragmentManager(), frameLayoutList, tabLayoutList);
        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);
        viewPager.setOffscreenPageLimit(2);

    }

    @Override
    public void onPause() {
        super.onPause();

    }
}
